package com.example.demo.controller;

import com.example.demo.bean.Barrage;
import com.example.demo.service.ChatService;
import io.swagger.annotations.Api;
import jakarta.annotation.Resource;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*
 * @Author:大力王
 * @Date:2024/3/31-31-4:04
 * 开始了
 */
@Api(tags = "聊天接口")
@RestController
@RequestMapping("/chat")
public class ChatController {

    @Resource
    private ChatService chatService;

    @MessageMapping("/send")
    @SendTo("/topic/barrage")
    public Barrage send(Barrage barrage) throws Exception {
        // 在这里可以处理弹幕的逻辑，比如存储到数据库
        return barrage;
    }
}
